﻿package controller;

import bean.PrizeWinningInfo;
import biz.PrizeWinningBiz;
import com.alibaba.fastjson.JSONArray;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import util.PreAddCallback;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/prizewinning")
public class PrizeWinningController {

    @Autowired
    private PrizeWinningBiz pwb;


    @RequestMapping(value="/insertLiveBroadcastNumber")
    @ResponseBody
    public String insertLiveBroadcastNumber(Integer liveBroadcastNumber){

        pwb.insertLiveBroadcastNumber(liveBroadcastNumber);

        return "插入直播号！";
    }


    @RequestMapping(value="/insertWinningBonusvenue")
    @ResponseBody
    public  String insertWinningBonusvenue(@Param("liveBroadcastNumber") Integer liveBroadcastNumber,@Param("statement") Integer statement ){

       pwb.insertWinningBonusvenue(liveBroadcastNumber,statement);

        return "插入奖金数！";
    }
    //给用户加状态
    @RequestMapping(value="/addStatementByUsersId")
    @ResponseBody
    public  String addStatementByUsersId(@Param("usersId") Integer usersId,@Param("statement") Integer statement){
         pwb.addStatementByUsersId(usersId,1);
        return "加状态！";
    }
    //给获奖表放入获奖用户信息（通过用户id）
    @RequestMapping(value="/addInfo")
    @ResponseBody
    public  String addInfo(){
        pwb.addInfo();
        return "插入用户信息!";
    }

    //显示获奖信息(用户头像 真名  平分多少钱)
    @RequestMapping(value="/showInfo")
    @ResponseBody
    public  String showInfo(@Param("statment") Integer statment,String callback){
        return PreAddCallback.preAddCallback(JSONArray.toJSONString(pwb.showInfo(statment)),callback);
    }



    //将本场获得奖金存入用户表中
    @RequestMapping(value="/saveMoney")
    @ResponseBody
    public  String saveMoney(@Param("usersId") Integer usersId ){
        pwb.saveMoney(usersId);
        return "存钱！";
    }


}
